import { loginApi } from '@/api/login'
import { setToken } from '@/utils/token'
import { Button } from 'antd'
import { useNavigate } from 'react-router-dom'
import { ProForm, ProFormText, ProFormDatePicker } from '@ant-design/pro-components'

export default function Login() {
  const navigate = useNavigate()
  const handleLogin = async () => {
    const { code, data } = await loginApi({
      account: 'chenda',
      password: '123456'
    })
    if (code === 0) {
      setToken(data.token)
    }
    navigate('/')
  }
  const handleSubmit = () => {}
  return (
    <div className="bg-[url('@/assets/img/login-bg.png')] h-screen min-h-[600px] min-w-[1200px] relative">
      <div className="absolute right-0 flex items-center h-full p-10 bg-white min-w-[700px]">
        <ProForm onFinish={handleSubmit} className="w-full">
          <ProFormText
            name="name"
            label="姓名"
            placeholder="请输入姓名"
            rules={[{ required: true, message: '姓名是必填项' }]}
          />
          <ProFormDatePicker name="date" label="日期" />
        </ProForm>
      </div>
      <Button type="primary" onClick={handleLogin}>
        登录
      </Button>
    </div>
  )
}
